package com.ncr.travel.appmgr.client.service;

import com.ncr.nep.dashboardcore.rest.client.HTTPRequest;
import com.ncr.nep.dashboardcore.rest.client.JSONCallback;
import com.ncr.travel.appmgr.client.MockAppManagerResources;

public class MockWebServiceImpl implements AppManagerWebService {

	@Override
	public void doPost(String subsubpath, HTTPRequest request, JSONCallback<?> callback) {
		if (subsubpath == null)
			return;
		if (subsubpath.equals("/updateScreenConfiguration")) {
			callback.onSuccess(getNotYetSupported());
		}
	}

	@Override
	public void doGet(String subpath, 
            HTTPRequest request, JSONCallback<?> callback) {
		if (subpath == null)
			callback.onSuccess("Path is null");
		if (subpath.equals("/products?userName=testUser")) {
			callback.onSuccess(getProductsConfiguration());
		} else if (subpath.endsWith("/BaseCheckInApp&ReEntryPassengerSelection")) {
			callback.onSuccess(getBaseCheckInAppReEntryPassengerSelection());
		} else if (subpath.endsWith("/Base Check-in App&Attract Screen")) {
			callback.onSuccess(getBaseCheckinAppAttractScreen());
		} else if (subpath.endsWith("/Base Check-in App&Find By Options")) {
			callback.onSuccess(getBaseCheckinAppFindByOptions());
		} else if (subpath.endsWith("/Base Check-in App&Select Passenger&Add Mileage Plan")) {
			callback.onSuccess(getWebCheckInBaseCheckInPassengerSelectionAddMileagePlan());
		} else if (subpath.endsWith("/Base Check-in App&Select Passenger&Special Service Requests Code")) {
			callback.onSuccess(getBaseCheckinAppSelectPassengerSpecialServiceRequestCodes());
		} else if (subpath.endsWith("/Base Check-in App&Secure Flight&Secure Flight Data Entry")) {
			callback.onSuccess(getBaseCheckinAppSecureFlightSecureFlightDataEntry());
		} else if (subpath.endsWith("/Base Check-in App&Thank You Screen&Thank You-1")) {
			callback.onSuccess(getBaseCheckinAppThankYouScreenThankYou1());
		} else if (subpath.endsWith("/Global&General Processing")) {
			callback.onSuccess(getGlobalGeneralProcessing());
		} else if (subpath.endsWith("/Global&Language Options")) {
			callback.onSuccess(getGlobalLanguageOptions());
		} else if (subpath.endsWith("/Global&Logo")) {
			callback.onSuccess(getGlobalLogo());
		} else if (subpath.endsWith("/Global&Errors&Check-In")) {
			callback.onSuccess(getGlobalErrorsCheckin());
		} else if (subpath.endsWith("/Global&Passenger Selection&Passenger Selection")){
		    callback.onSuccess(getKioskGlobalPassengerSelection());
		} else if (subpath.endsWith("/Global&Passenger Selection&Add Mileage Plan")) {
		    callback.onSuccess(getKioskGlobalPassengerSelectionAddMileagePlan());
		} else if (subpath.endsWith("/Global&Passenger Selection&Mileage Plan Selection")) {
            callback.onSuccess(getKioskGlobalPassengerSelectionMileagePlanSelection());
        } else if(subpath.endsWith("/Base Check-in App&Select Passenger&Passenger Selection")) {
            callback.onSuccess(getWebCheckinBaseCheckInPassengerSelectionPassengerSelection());
        } else  if(subpath.endsWith("/Base Check-in App&Special Service Requests")) {
            callback.onSuccess(getWebCheckInBaseCheckInSpecialRequest());
        } else {
			callback.onSuccess(getProductsConfiguration());
		}
	}
	
	private String getBaseCheckinAppAttractScreen() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppAttractScreen().getText();
	}

	private String getBaseCheckInAppReEntryPassengerSelection() {
		return MockAppManagerResources.INSTANCE.baseCheckInAppReEntryPassengerSelection().getText();
	}

	private String getBaseCheckinAppSelectPassengerAddMileagePlan() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppSelectPassengerAddMileagePlan().getText();
	}

	private String getBaseCheckinAppFindByOptions() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppFindByOptions().getText();
	}

	private String getGlobalErrorsCheckin() {
		return MockAppManagerResources.INSTANCE.globalErrorsCheckin().getText();
	}

	private String getBaseCheckinAppThankYouScreenThankYou1() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppThankYouScreenThankYou1().getText();
	}

	private String getBaseCheckinAppSecureFlightSecureFlightDataEntry() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppSecureFlightSecureFlightDataEntry().getText();
	}

	private String getBaseCheckinAppSelectPassengerSpecialServiceRequestCodes() {
		return MockAppManagerResources.INSTANCE.baseCheckinAppSelectPassengerSpecialServiceRequestsCode().getText();
	}

	private String getGlobalGeneralProcessing() {
		return MockAppManagerResources.INSTANCE.globalGeneralProcessing().getText();
	}

	private String getGlobalLanguageOptions() {
		return MockAppManagerResources.INSTANCE.globalLanguageOptions().getText();
	}

	private String getGlobalLogo() {
		return MockAppManagerResources.INSTANCE.globalLogo().getText();
	}

	private String getProductsConfiguration() {
		return MockAppManagerResources.INSTANCE.products().getText();
	}

	private String getKioskGlobalPassengerSelection() {
	    return MockAppManagerResources.INSTANCE.kioskGlobalPassengerSelection().getText();
	}
	
	private String getKioskGlobalPassengerSelectionAddMileagePlan() {
	    return MockAppManagerResources.INSTANCE.kioskGlobalPassengerSelectionAddMileagePlan().getText();
	}
	
	private String getKioskGlobalPassengerSelectionMileagePlanSelection() {
	    return MockAppManagerResources.INSTANCE.kioskGlobalPassengerSelectionMileagePlanSelection().getText();
	}
	
	private String getWebCheckInBaseCheckInPassengerSelectionAddMileagePlan() {
	    return MockAppManagerResources.INSTANCE.webCheckInBaseCheckInPassengerSelectionAddMileagePlan().getText();    
	}
	
	private String getWebCheckinBaseCheckInPassengerSelectionPassengerSelection() {
	    return MockAppManagerResources.INSTANCE.webCheckinBaseCheckInPassengerSelectionPassengerSelection().getText();
	}
	
	public String getWebCheckInBaseCheckInSpecialRequest() {
	    return MockAppManagerResources.INSTANCE.webCheckInBaseCheckInSpecialRequest().getText();
	}
	
	private String getScreenConfiguration() {
		return MockAppManagerResources.INSTANCE.configXml().getText();
	}
	
	private String getNotYetSupported() {
		StringBuilder error = new StringBuilder();
		error.append("{\"errorCode\":");
		error.append("200");
		error.append(",\"errorMessage\":\"");
		error.append("Not Yet Supported");
		error.append("\"}");
		return error.toString();
	}
}
